//
//  PublishRentInfoCell.m
//  CenturyCity
//
//  Created by beisheng03 on 2017/12/26.
//  Copyright © 2017年 beisheng. All rights reserved.
//

#import "PublishRentInfoCell.h"

@interface PublishRentInfoCell ()
@property (weak, nonatomic) IBOutlet UILabel *leftLabel;
@property (weak, nonatomic) IBOutlet UILabel *rightLabel;
@property (weak, nonatomic) IBOutlet UITextField *middleTextField;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *bottomMargin;
@property (weak, nonatomic) IBOutlet UIImageView *leftImageView;

@end

@implementation PublishRentInfoCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.contentView.backgroundColor = [UIColor whiteColor];
    
    self.bottomMargin.constant = 0;
    
    self.leftLabel.font = MYFONT(16);
    
    self.rightLabel.font = MYFONT(14);
    
    self.middleTextField.font = MYFONT(14);
    
    
//    self.rightLabel.textColor = [UIColor redColor];
    
    self.leftLabel.textColor = darkGray;
    // Initialization code
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(textChange) name:UITextFieldTextDidChangeNotification object:self.middleTextField];
    
    
}

- (void)setModel:(HouseParameterModel *)model{
    
    _model = model;
    
    self.rightLabel.textColor = [UIColor blackColor];
    
    
    if (self.index.row == 0) {
        
    } else if (self.index.row == 1){
        
        if (_model.renting_style_name.length > 0) {
    
            self.rightLabel.text = _model.renting_style_name;
        }
        
    }else if (self.index.row == 2){
        
        if (_model.house_price.length > 0) {
            
            self.middleTextField.text = _model.house_price;
        }
        
    }else if (self.index.row == 3){
        
        if (_model.pay_class_method.length > 0) {
            
            self.rightLabel.text = _model.pay_class_method;
        }
        
    }else if (self.index.row== 4){
        
        if (_model.huXing_name.length > 0) {
            
    
            self.rightLabel.text = _model.huXing_name;
        }
        
    }else if (self.index.row == 5){
        
        if (_model.house_area.length > 0) {
            
            self.middleTextField.text = _model.house_area;
        }
        
    }else if (self.index.row == 6){
        
        if (_model.house_type_name.length > 0) {
            
            self.rightLabel.text = _model.house_type_name;
        }
        
        
    }else if (self.index.row == 7){
        
        if (_model.house_face_name.length > 0) {
            
            self.rightLabel.text = _model.house_face_name;
        }
        
    }else if (self.index.row == 8){
        
        
        if (_model.house_floor.length > 0) {
            
            self.middleTextField.text = _model.house_floor;
        }
        
        
    }else if (self.index.row == 9){
        
        if (_model.house_decorate_name.length > 0) {
            
            self.rightLabel.text = _model.house_decorate_name;
        }
        
    }else if (self.index.row == 11){
        
        if (_model.house_language_name.length > 0) {
            
            self.rightLabel.text = _model.house_language_name;
        }
    }else if (self.index.row == 12){
        
        
        if (_model.lastString.length > 0) {
            

            
            self.rightLabel.text = _model.lastString;
        }
        
        
    }
    
    

    
    
}

//- (void)layoutSubviews{
//
//
//    [super layoutSubviews];
//
//    [self.rightLabel sizeToFit];
//}


- (void)textChange{
    
    if (self.index.row == 0) {
        
    } else if (self.index.row == 1){
        
     
        
    }else if (self.index.row == 2){
        
    self.model.house_price = self.middleTextField.text;
        
    }else if (self.index.row == 3){
        
    }else if (self.index.row== 4){
        
    }else if (self.index.row == 5){
        
    self.model.house_area = self.middleTextField.text;

    }else if (self.index.row == 6){
        
    }else if (self.index.row == 7){
        
    }else if (self.index.row == 8){
        
    self.model.house_floor = self.middleTextField.text;

    }else if (self.index.row == 9){
        
    }else if (self.index.row == 11){
        
    }else if (self.index.row == 12){
        
    }else if (self.index.row == 13){
        
        
    }
    
    

    
}



//佛挡杀佛的发
- (void)setIndex:(NSIndexPath *)index{
    
    _index = index;
    
    self.leftImageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"rentPulish00%ld",_index.row]];

    
    self.middleTextField.hidden = YES;
    
    self.rightLabel.text = nil;
    
    if (index.row == 0) {
        
        self.leftLabel.text = @"房源位置:";
//        self.rightLabel.text = @"金太阳城堡";
        
    } else if (index.row == 1){
        
        self.leftLabel.text = @"租赁方式:";
//        self.rightLabel.text = @"整租";
        
    }else if (index.row == 2){
        
        self.leftLabel.text = @"租金:";
        self.rightLabel.text = @"P/月";
        self.middleTextField.hidden = NO;
        self.middleTextField.placeholder = @"期望租金";

    }else if (index.row == 3){
        
        self.leftLabel.text = @"付款方式:";
//        self.rightLabel.text = @"押一付三";
        
   
        
    }else if (index.row == 4){
        
        self.leftLabel.text = @"户型:";
//        self.rightLabel.text = @"三室一厅";
        
 
    }else if (index.row == 5){
        self.leftLabel.text = @"面积:";
        self.rightLabel.attributedText = [self attributedStringWithStr];
        self.middleTextField.hidden = NO;
        self.middleTextField.placeholder = @"房屋面积";

     
    }else if (index.row == 6){
        self.leftLabel.text = @"房源类型:";
//        self.rightLabel.text = @"loft";
        

    }else if (index.row == 7){
        self.leftLabel.text = @"房屋朝向:";
//        self.rightLabel.text = @"南北通透";

        
    }else if (index.row == 8){
        
        self.leftLabel.text = @"楼层:";
        
        self.rightLabel.text = @"F";
        self.middleTextField.hidden = NO;
        self.middleTextField.placeholder = @"房源楼层";
        

        
    }else if (index.row == 9){
        
        self.leftLabel.text = @"装修类型:";
//        self.rightLabel.text = @"普通装修";
        
   
    }else if (index.row == 10){
        
//        self.leftLabel.text = @"联系电话:";
        //        self.rightLabel.text = nil;
        
      
        
    }else if (index.row == 11){
        

        
        self.leftLabel.text = @"交流语言:";
        //        self.rightLabel.text = nil;
        
       
        
    }else if (index.row == 12){

        
        self.leftLabel.text = @"所在区域:";
        //        self.rightLabel.text = nil;
        
        
    }
    
    
}



- (NSMutableAttributedString *)attributedStringWithStr{
    
    UIFont *bigFont = MYFONT(16);
    //    UIFont *smallFont = MYFONT(7);
    NSMutableAttributedString *attributeString6 = [[NSMutableAttributedString alloc] init];
    NSAttributedString *string26 = [[NSAttributedString alloc] initWithString:@"m" attributes:@{NSFontAttributeName : bigFont,NSForegroundColorAttributeName : [UIColor blackColor],NSBaselineOffsetAttributeName : @(0)}];
    NSAttributedString *string27 = [[NSAttributedString alloc] initWithString:@"2" attributes:@{NSFontAttributeName : MYFONT(7),NSForegroundColorAttributeName : [UIColor blackColor],NSBaselineOffsetAttributeName : @(8)}];
    
    [attributeString6 appendAttributedString:string26];
    [attributeString6 appendAttributedString:string27];
    
    return attributeString6;
    
    
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
